You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
595 B
21 lines
595 B
import { requireAdmin } from "#server/utils/admin-guard";
|
|
import { executeAgentTool } from "#server/service/agent-tool";
|
|
|
|
export default defineWrappedResponseHandler(async (event) => {
|
|
const user = await requireAdmin(event);
|
|
|
|
const id = getRouterParam(event, "id");
|
|
if (!id) {
|
|
return R.throwError(400, "无效的工具ID", null);
|
|
}
|
|
|
|
const body = await readBody(event);
|
|
const { input } = body;
|
|
|
|
if (input === undefined) {
|
|
return R.throwError(422, "input 不能为空", null);
|
|
}
|
|
|
|
const result = await executeAgentTool(id, input, user.id);
|
|
return R.success(result);
|
|
});
|
|
|